using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TiGaCreateSpeEff : CreateObject
{

    public GameObject PurpleHead;
    public GameObject RedHead;
    public GameObject BackHead;
    public Vector2 ChangeHeadDev;
    public GameObject PurpleBody;
    public GameObject RedBody;
    public Vector2 ChangeBodyDev;


    public GameObject ZPLARay1;
    public Vector2 ZPLARay1Dev;
    public GameObject ZPLARay2;
    public Vector2 ZPLARay2Dev;
    public GameObject ZPLARay3;
    public Vector2 ZPLARay3Dev;
    public GameObject ZPLARay4;
    public Vector2 ZPLARay4Dev;
    public GameObject ZPLARay5;
    public Vector2 ZPLARay5Dev;
    public GameObject ZPLARay6;
    public Vector2 ZPLARay6Dev;
    public GameObject ZPLARay7;
    public Vector2 ZPLARay7Dev;

    public GameObject DLXMRayBall;
    private GameObject createdDLXMRayBall;
    public Vector2 DLXMRayBallDev;

    public GameObject DLXMRay1;
    public Vector2 DLXMRay1Dev;
    public GameObject DLXMRay2;
    public Vector2 DLXMRay2Dev;
    public GameObject DLXMRay3;
    public Vector2 DLXMRay3Dev;
    public GameObject DLXMHead;
    public Vector2 DLXMHeadDev;

    public GameObject LRPTBomb1;
    public Vector2 LRPTBomb1Dev;
    public GameObject LRPTBomb2;
    public Vector2 LRPTBomb2Dev;
    public GameObject LRPTBomb3;
    public Vector2 LRPTBomb3Dev;
    public GameObject LRPTBomb4;
    public Vector2 LRPTBomb4Dev;
    public GameObject LRPTBomb4Back;
    public Vector2 LRPTBomb4BackDev;
    public GameObject LRPTBomb5;
    public Vector2 LRPTBomb5Dev;
    public GameObject LRPTBombLight;
    public Vector2 LRPTBombLightDev;
    private GameObject createdLRPTBombLight;
    public GameObject LRPTBomb;
    public Vector2 LRPTBombDev;
    public GameObject HandRay;
    public Vector2 HandRayDev;
    public GameObject SPXMRay;
    public Vector2 SPXMRayDev;
    public GameObject StrongZPLARayEffect;
    public Vector2 StrongZPLARayEffectDev;

    private TiGaSoundManager soundManager;


    new void Start()
    {
        base.Start();
        soundManager = GetComponentInChildren<TiGaSoundManager>();
    }


    public void CreateZPLARay1()
    {
        CreateEffects(ZPLARay1, ZPLARay1Dev);
    }
    public void CreateZPLARay2()
    {
        CreateEffects(ZPLARay2, ZPLARay2Dev);
    }
    public void CreateZPLARay3()
    {
        CreateEffects(ZPLARay3, ZPLARay3Dev);
    }
    public void CreateZPLARay4()
    {
        CreateEffects(ZPLARay4, ZPLARay4Dev);
    }
    public void CreateZPLARay5()
    {
        CreateEffects(ZPLARay5, ZPLARay5Dev);
    }
    public void CreateZPLARay6()
    {
        CreateEffects(ZPLARay6, ZPLARay6Dev);
    }
    public void CreateZPLARay7()
    {
        CreateEffects(ZPLARay7, ZPLARay7Dev);
    }



    public void CreateDLXMRayBall()
    {
        Vector3 createPos = new Vector3(transform.position.x + DLXMRayBallDev.x * character.GetScaleX(), transform.position.y + DLXMRayBallDev.y, transform.position.z);
        createdDLXMRayBall = Instantiate(DLXMRayBall, createPos, transform.rotation);
    }

    public void DLXMRayBallMoveX(float offsetX)
    {
        createdDLXMRayBall.GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
        Vector2 pos = createdDLXMRayBall.transform.position;
        createdDLXMRayBall.transform.position = new Vector2(transform.position.x + offsetX * character.GetScaleX(), pos.y);
    }
    public void DLXMRayBallMoveY(float offsetY)
    {
        createdDLXMRayBall.GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
        Vector2 pos = createdDLXMRayBall.transform.position;
        createdDLXMRayBall.transform.position = new Vector2(pos.x, transform.position.y + offsetY);
    }

    public void DLXMRayBallShot()
    {
        createdDLXMRayBall.GetComponent<DLXMRayBallController>().shot(character.GetScaleX());
    }

    public void CreateDLXMRay1()
    {
        CreateEffects(DLXMRay1, DLXMRay1Dev);
    }

    public void CreateDLXMRay2()
    {
        CreateEffects(DLXMRay2, DLXMRay2Dev);
    }
    public void CreateDLXMRay3()
    {
        CreateEffects(DLXMRay3, DLXMRay3Dev);
    }

    public void CreateDLXMHead()
    {
        CreateFlyingAttack(DLXMHead, DLXMHeadDev);
    }

    public void CreateLRPTBomb1()
    {
        CreateEffects(LRPTBomb1, LRPTBomb1Dev);
    }
    public void CreateLRPTBomb2()
    {
        CreateEffects(LRPTBomb2, LRPTBomb2Dev);
    }

    public void CreateLRPTBomb3()
    {
        CreateEffects(LRPTBomb3, LRPTBomb3Dev);
    }

    public void CreateLRPTBomb4()
    {
        CreateEffects(LRPTBomb4, LRPTBomb4Dev);
    }
    public void CreateLRPTBomb4Back()
    {
        CreateEffects(LRPTBomb4Back, LRPTBomb4BackDev);
    }


    public void CreateLRPTBomb5()
    {
        CreateEffects(LRPTBomb5, LRPTBomb5Dev);
    }
    public void CreateLRPTBombLight()
    {
        createdLRPTBombLight = CreateEffects(LRPTBombLight, LRPTBombLightDev);
    }

    public void LRPTBombLightMoveX(float offsetX)
    {
        Vector2 pos = createdLRPTBombLight.transform.position;
        createdLRPTBombLight.transform.position = new Vector2(transform.position.x + offsetX * character.GetScaleX(), pos.y);
    }
    public void LRPTBombLightMoveY(float offsetY)
    {
        Vector2 pos = createdLRPTBombLight.transform.position;
        createdLRPTBombLight.transform.position = new Vector2(pos.x, transform.position.y + offsetY);
    }
    public void CreateLRPTBomb()
    {
        CreateFlyingAttack(LRPTBomb, LRPTBombDev);

    }

    public void CreateStrongZPLARayEffect()
    {
        CreateEffects(StrongZPLARayEffect, StrongZPLARayEffectDev);
    }

    public void CreateHandRay()
    {
        CreateFlyingAttack(HandRay, HandRayDev);

    }
    private void CreateSPXMRay()
    {
        CreateFlyingAttack(SPXMRay, SPXMRayDev);
    }
    public void SPXMRayShot(float delayTime)
    {
        InvokeRepeating("CreateSPXMRay", 0.05f, delayTime);
    }
    public void SPXMRayStop()
    {
        CancelInvoke("CreateSPXMRay");
    }


    public void CreateHead()
    {
        int changeForm = animator.GetInteger("change_form");
        soundManager.PlayChangeHead();
        switch (changeForm)
        {
            case 0:
                CreateEffects(BackHead, ChangeHeadDev);
                break;
            case 1:
                CreateEffects(PurpleHead, ChangeHeadDev);
                break;
            case 2:
                CreateEffects(RedHead, ChangeHeadDev);
                break;
        }  
    }
    public void CreatePurpleBody()
    {
        CreateEffects(PurpleBody, ChangeBodyDev);
        soundManager.PlayChangeForm();
        //soundsManager.PlayWarRoar(2);
    }
    public void CreateRedBody()
    {
        CreateEffects(RedBody, ChangeBodyDev);
        soundManager.PlayChangeForm();
        //soundsManager.PlayWarRoar(2);
    }

   
  
}
